package com.forlove.app.qselect.index.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;

import com.forlove.app.R;
import com.forlove.app.common.base.mvp.presenter.IBasePresenter;
import com.forlove.app.common.utils.LogUtil;
import com.forlove.app.common.utils.MyTimeUtils;
import com.forlove.app.common.widget.recyview.BaseRecyclerAdapter;
import com.forlove.app.common.widget.recyview.ViewHolder;
import com.forlove.app.qselect.index.entity.FriendCircleInfoEntity;

import java.text.ParseException;
import java.util.Date;
import java.util.List;

/**
 * Created by yjl on 2017/10/11.
 */

public class MineCircleAdapter extends BaseRecyclerAdapter<FriendCircleInfoEntity> {

    private IBasePresenter basePresenter;

    public MineCircleAdapter(Context context, int itemView, List<FriendCircleInfoEntity> mDatas, IBasePresenter basePresenter) {
        super(context, itemView, mDatas);
        this.basePresenter = basePresenter;
    }

    @Override
    protected void convertView(ViewHolder holder, FriendCircleInfoEntity entity, int position) {
        Date data = new Date(entity.addtime * 1000);
        String time = "";

        try {
            time = MyTimeUtils.friendlyFormat(data);
        } catch (ParseException e) {
            LogUtil.e(e.getMessage());
        }
        if (TextUtils.isEmpty(time)) {
            time = MyTimeUtils.formatDate(new Date(entity.addtime * 1000), "MM月DD日HH时mm分");
        }
        holder.setText(R.id.text_circle_time, time + "");
        holder.setText(R.id.text_circle_from, entity.info + "");
        if (entity.isread == 0) {
//            holder.setBackgroundRes(R.id.view_mine_charm, R.mipmap.bg_mine_charm);
            if (entity.mSex == 1) {
                holder.setBackgroundRes(R.id.image_circle_sex, R.mipmap.image_diamond_blue_charm);
            } else if (entity.mSex == 2) {
                holder.setBackgroundRes(R.id.image_circle_sex, R.mipmap.image_diamond_red_charm);
            }
            holder.setTextColor(R.id.text_circle_time, Color.parseColor("#b2d6e6"));
        } else if (entity.isread == 1) {
//            holder.setBackgroundRes(R.id.view_mine_charm, R.mipmap.bg_mine_charm_gray);
            holder.setBackgroundRes(R.id.image_circle_sex, R.mipmap.image_diamond_gray_charm);
            holder.setTextColor(R.id.text_circle_time, Color.parseColor("#bbbbbb"));
        }
    }
}
